<?php
include '../data/white_dal.php';

class WhiteMng
{
    function update($mysqli, $whiteEntity)
    {
        $whiteDAL = new WhiteDAL();
        return $whiteDAL->update($msyqli,
                                 $whiteEntity->id,
                                 $whiteEntity->rfqID,
                                 $whiteEntity->dioxideContent,
                                 $whiteEntity->dioxideType,
                                 $whiteEntity->carrierType,
                                 $whiteEntity->endApp,
                                 $whiteEntity->fillerRequired,
                                 $whiteEntity->specialRequirement,
                                 $whiteEntity->inTime,
                                 $whiteEntity->inUser);
    }

    function get($mysqli, $id)
    {
        $where  = "id = " . $id;
        $whiteDAL = new WhiteDAL();
        if ($result = $whiteDAL->get($mysqli, $where)) {
            return $result->fetch_array();
        } else {
            return false;
        }
    }

    function getAll($mysqli, $start, $pageSize, $sortField, $sortDirection)
    {
        $orderBy = "ORDER BY " . $sortField . " " . $sortDirection . " LIMIT " . $start . ", " . ($pageSize * ($start + 1));
        $whiteDAL = new WhiteDAL();
        if ($result = $whiteDAL->getAll($mysqli, $orderBy)) {
            while ($row = $result->fetch_array()) {
                $whiteList[] = $row;
            }
            return $whiteList;
        } else {
            return false;
        }
    }

    function delete($mysqli, $id)
    {
        $whiteDAL = new WhiteDAL();
        return $whiteDAL->delete($mysqli, $id);
    }
}

?>
